package com.sl.biz.modular.process.controller;

import com.sl.biz.modular.process.controller.request.ProcessRelationConfigProcessAndVersionListRequest;
import com.sl.biz.modular.process.controller.request.ProcessRelationConfigSaveRequest;
import com.sl.biz.modular.process.controller.request.ProcessRelationConfigUpdateParamByIdRequest;
import com.sl.biz.modular.process.controller.request.ProcessRelationConfigVersionListRequest;
import com.sl.biz.modular.process.controller.response.ProcessRelationVersionListVO;
import com.sl.biz.modular.process.service.ProcessRelationConfigBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/process/relation")
@RequiredArgsConstructor
public class ProcessRelationConfigController {

    private final ProcessRelationConfigBizService processRelationConfigBizService;


    @PostMapping("/save")
    public Boolean save(@RequestBody ProcessRelationConfigSaveRequest processRelationConfigSaveRequest) {
        return processRelationConfigBizService.save(processRelationConfigSaveRequest);
    }

    @PostMapping("/remove/{id}")
    public Boolean remoteById(@PathVariable("id") String id) {
        return processRelationConfigBizService.remoteById(id);
    }

    @PostMapping("/version/list")
    public List<ProcessRelationVersionListVO> versionList(@RequestBody ProcessRelationConfigVersionListRequest versionListRequest) {
        return processRelationConfigBizService.versionList(versionListRequest);
    }

    @PostMapping("/list")
    public List<ProcessRelationVersionListVO> processAndVersionList(@RequestBody ProcessRelationConfigProcessAndVersionListRequest versionListRequest) {
        return processRelationConfigBizService.processAndVersionList(versionListRequest
                .getBizId(), versionListRequest.getBizType());
    }


    @PostMapping("/update_params")
    public Boolean updateParamsById(@RequestBody ProcessRelationConfigUpdateParamByIdRequest updateParamByIdRequest) {
        return processRelationConfigBizService.updateParamsById(updateParamByIdRequest);
    }
}
